Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
A tiny get function', similar to Lodash.get
Add dash-get
to your project via npm install
:
npm install --save dash-get
You can easily retrieve a value from a (deeply) nested object with dash-get
, like so:
import get from 'dash-get'
const someObject = {...}
const deeplyNestedValue = get(someObject, 'the.path.to.the.nested.value')
// value
The path could also be an Array
:
const someObject = {...}
const deeplyNestedValue = get(someObject, ['the', 'path', 'to', 'the', 'nested', 'value'])
// value
get(obj, path, fallback)
Argument | Type | Description |
---|---|---|
obj | Object | The object to get the value from. |
path | Array<string> /string | The path to the value. |
fallback | any | The fallback value, in case the desired value could not be retrieved. |
This module does not support this particular use case:
get(object, 'a[0].b.c')
You totally don't have to npm install
this. This exists for convenience purposes 😊.
In fact, it's encouraged that you add the get
code to your code base! One less depenency to install and manage.
Here it is!
function get(obj, path, fallback) {
if (!obj || !path) return fallback;
const paths = Array.isArray(path) ? path : path.split(".");
let results = obj;
let i = 0;
while (i < paths.length && results !== undefined && results !== null) {
results = results[paths[i]];
i++;
}
if (i === paths.length) {
return results !== undefined ? results : fallback;
}
return results !== undefined && results !== null ? results : fallback;
}
Thanks to @knicklabs for pairing with me on this one!
FAQs
A tiny get function, similar to Lodash.get
The npm package dash-get receives a total of 168,555 weekly downloads. As such, dash-get popularity was classified as popular.
We found that dash-get demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.